﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FindChild : MonoBehaviour {

	// Use this for initialization
	void Start () {
        Transform tf = FindKid(this.transform,"XX");
        tf.name = "YY";
	}
	
	// Update is called once per frame
	void Update () {
		
	}
    public Transform FindKid(Transform tf,string name)
    {
        foreach(Transform item in tf)
        {
            if(item.name == name)
            {
                return item;
            }
            else
            {
                if (item.childCount > 0)
                {
                    Transform res = FindKid(item, name);
                    if(res != null)
                    {
                        return res;
                    }
                }
            }
        }
        return null;
    }

}
